
if( typeof(LofSlideshow) == 'undefined' ){
	var LofFlashContent = new Class( {
		initialize:function( eMain, eNavigator, options ){
			this.setting = Object.extend({
				enableNavigator : true,
				navigator		: null,
				autoStart		: true,
				descStyle	    : 'sliding',
				mainItemClass		: '.lof-main-item',
				navigatorItemClass  : '.lof-navigator-item' ,
				navigatorEvent		: 'click',
				interval	  	 	:2000
			}, options || {} );
			
			this.currentNo  = 0;
			this.nextNo     = null;
			this.previousNo = null;
			this.totalItems = 0;
			this.fxNavigatorImages=[];
			this.fxItems=[];	
			this.minSize = 0;
			
			if( $defined(eMain) ){
				this.slides = eMain.getElements( this.setting.mainItemClass );

				this.maxWidth  = eMain.getStyle('width').toInt();
				this.maxHeight = eMain.getStyle('height').toInt();
				this.totalItems = this.slides.length;
				 styleMode = this.__getStyleMode(); 
			
				var fx =  Object.extend({waiting:false, onComplete:this.onComplete.bind(this)}, this.setting.fxObject );
				
		
				if( styleMode[0] != 'z-index' ) {
				
					this.slides.each( function(item, index) {
						item.setStyles( eval('({"'+styleMode[0]+'": index * this.maxSize,"'+styleMode[1]+'":Math.abs(this.maxSize),"display" : "block"})') );			   
						this.fxItems[index] = new Fx.Style( item, styleMode[0], fx );
					}.bind(this) );
					if( styleMode[0] == 'opacity' || styleMode[0] =='z-index' ){
						this.slides[0].setStyle(styleMode[0],'1');
					}
				}
			}
			if( $defined(eNavigator) ){
				this.navigatorItems = eNavigator.getElements( this.setting.navigatorItemClass );
				this.navigatorItems.each( function(item,index) {
					var image = item.getElement('img');
					if( $defined(image) ){
						this.fxNavigatorImages[index] = new Fx.Style( image,'opacity',{transition:Fx.Transitions.Bounce.easeInOut, duration:800} );
					}
					
					item.addEvent( this.setting.navigatorEvent, function(){
																		 
						if( $defined(this.fxNavigatorImages[index]) ){
							this.jumping( index, true );
							this.setNavActive( index, item );				
						}
					}.bind(this) );
				}.bind(this) );
				// alert(  )
			}
				this.setNavActive( 0 );
		},
		setNavActive:function( index, item ){
				this.fxNavigatorImages[index].stop().start(0.3, 1);
						//	this.currentNo = index;

				this.navigatorItems.removeClass('active');
				this.navigatorItems[index].addClass('active');	
		},
		__getStyleMode:function(){
			switch( this.setting.layoutStyle ){
				case 'opacity': this.maxSize=0; this.minSize=1; return ['opacity','opacity'];
				case 'z-index':this.maxSize=1;this.minSize=0; return ['z-index','z-index'];
				case 'vrup': this.maxSize=this.maxHeight; return ['top','height'];
				case 'vrdown':this.maxSize=-this.maxHeight;  return ['top','height'];
				case 'hrright': this.maxSize=-this.maxWidth; return ['left','width'];
				case 'hrleft':
				default: this.maxSize=this.maxWidth; return ['left','width'];
			}
		},
		registerButtonsControl:function( eventHandler, objects ){
			if( $defined(objects) && this.totalItems > 1 ){
				for( var action in objects ){
					if( $defined(this[action.toString()])  && $defined(objects[action]) ){
				
						objects[action].addEvent( eventHandler, this[action.toString()].bind(this, [true]) );
			
					}
				}
			}
			return this;	
		},
		start:function( isStart ){
			this.setting.auto = isStart;
			if( isStart && this.totalItems > 0 ){this.play( this.setting.interval,'next', true );}
		},
		onComplete:function(){
		// 	this.slides[this.currentNo].setStyle('z-index',0);
		},	
		onProcessing:function( item, manual, start, end ){
		
			this.previousNo = this.currentNo + (this.currentNo>0 ? -1 : this.totalItems-1);
			this.nextNo 	= this.currentNo + (this.currentNo < this.totalItems-1 ? 1 : 1- this.totalItems);	
			if( manual ) { this.stop(); }
			return this;
		},
		finishFx:function( manual ){
			if( manual ) this.stop();
			if( manual && this.setting.auto )
				this.play( this.setting.interval,'next', true );
			
			this.setNavActive( this.currentNo );	
		},
		fxStart:function( index, start, end ){
			
			this.fxItems[index].stop().start( start , end );
			return this;
		},
		jumping:function( no, manual ){
			if( this.currentNo == no ) return;	
			this.onProcessing( null, manual, 0, this.maxSize )
				.fxStart( no, this.maxSize , this.minSize )
				.fxStart( this.currentNo, this.minSize,  -this.maxSize )
				.finishFx( manual );	
					this.currentNo  = no;
		},
		next:function( manual, jump ){
			this.currentNo += (this.currentNo < this.totalItems-1) ? 1 : (1 - this.totalItems);	
			this.onProcessing( null, manual, 0, this.maxSize )
				.fxStart( this.currentNo, this.maxSize , this.minSize )
				.fxStart( this.previousNo, this.minSize,  -this.maxSize )
				.finishFx( manual );
		},
		previous:function( manual ){
			this.currentNo += this.currentNo > 0 ? -1 : this.totalItems - 1;
			this.onProcessing( null, manual, -this.maxWidth, this.minSize )
				.fxStart( this.nextNo, this.minSize, this.maxSize )
				.fxStart( this.currentNo, -this.maxSize, this.minSize )
				.finishFx( manual	);			
		},
		stop:function(){ $clear(this.isRun ); },
		play:function( delay, direction, wait ){
			this.stop(); 
			if(!wait){ this[direction](false); }
			this.isRun = this[direction].periodical(delay,this,false);
		}
	} );
}